package com.xyx.yfy_site_msg.system.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xyx.yfy_site_msg.system.entity.YfyLoginfo;
import com.xyx.yfy_site_msg.system.service.YfyLoginfoService;
import com.xyx.yfy_site_msg.system.utils.DataGridView;
import com.xyx.yfy_site_msg.system.vo.YfyLoginfoVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xyx
 * @since 2020-11-17
 */
@RestController
@RequestMapping("/loginfo")
public class YfyLoginfoController {

    @Autowired
    private YfyLoginfoService loginfoService;

    @RequestMapping("loadAllLoginfo")
    public DataGridView loadAllLoginfo(YfyLoginfoVo loginfoVo){
        IPage<YfyLoginfo> page=new Page<>(loginfoVo.getPage(),loginfoVo.getLimit());
        QueryWrapper<YfyLoginfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(loginfoVo.getLLoginname()),"L_LoginName",loginfoVo.getLLoginname());
        queryWrapper.orderByDesc("L_LoginTime");
        this.loginfoService.page(page,queryWrapper);
        return new DataGridView(page.getTotal(),page.getRecords());
    }

}

